﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DayPilot.Web.Ui.Recurrence;

namespace WebGui.Admin
{
    public partial class RecurrentEventEdit : Page
    {
        private RecurrenceRule _rule = RecurrenceRule.NoRepeat;

        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        private EventMode Mode
        {
            get
            {
                if (!String.IsNullOrEmpty(Request.QueryString["master"]))
                {
                    if (!String.IsNullOrEmpty(Request.QueryString["start"]))
                    {
                        return EventMode.NewException;
                    }
                    if (!String.IsNullOrEmpty(Request.QueryString["id"]))
                    {
                        return EventMode.Exception;
                    }
                    return EventMode.Master;
                }

                return EventMode.Regular;
            }

        }

        enum EventMode
        {
            Master,
            NewException,
            Exception,
            Regular
        }

        private DateTime Occurrence
        {
            get
            {
                return Convert.ToDateTime(Request.QueryString["start"]);
            }
        }

        protected string RecurrenceJson
        {
            get
            {
                return _rule.ToJson();
            }
        }

        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            try
            {


                Modal.Close(this, "OK");
            }catch(Exception ex)
            {
              Response.Write("<script type='text/javascript'>alert('" + ex.Message + "'); </script>");
            }
            
        }

        protected void ButtonCancel_Click(object sender, EventArgs e)
        {
            Modal.Close(this);
        }

    }
}